import request from '@/utils/request'
import store from '../store'
export function fetchList(query) {
  return request({
    url: '/mall/goods/page',
    method: 'get',
    params: query
  })
}

export function fetchMerchantPageList(query) {
  return request({
    url: '/mall/goods/pageMerchant',
    method: 'get',
    params: query
  })
}

export function delObj(id) {
  return request({
    url: '/mall/goods/del/' + id,
    method: 'delete'
  })
}

export function getObj(id) {
  return request({
    url: '/mall/goods/id/' + id,
    method: 'get'
  })
}

export function getMerchantGood(id) {
  return request({
    url: '/mall/merchantId/id/' + id,
    method: 'get'
  })
}
export function putObj(obj) {
  return request({
    url: '/mall/goods',
    method: 'put',
    data: obj
  })
}
export function addObj(obj) {
  return request({
    url: '/mall/goods',
    method: 'post',
    data: obj
  })
}
export function addMerchantObj(obj) {
  return request({
    url: '/mall/goods/merchantGood',
    method: 'post',
    data: obj
  })
}
// 上下架
export function SXJObj(id) {
  return request({
    url: '/mall/goods/SXJ/' + id,
    method: 'delete'
  })
}
// 推荐取消推荐
export function isShowObj(id) {
  return request({
    url: '/mall/goods/isShow/' + id,
    method: 'delete'
  })
}

export function getToken() {
  return 'Bearer ' + store.getters.token
}

